﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A2DFramework.QueueService
{
    /// <summary>
    /// 队列服务接口
    /// </summary>
    public interface IQueue
    {
        /// <summary>
        /// 建立队列
        /// </summary>
        /// <typeparam name="T"></typeparam>
        void CreateIfNotExists<T>();

        /// <summary>
        /// 客户端发送请求（第一步）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="msg"></param>
        /// <returns></returns>
        void SendRequest2Worker<T>(Message<T> msg);
        void SendRequest2Worker<T>(T msg);

        /// <summary>
        /// 后端Worker接收请求（第二步）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        Message<T> GetRequestFromClient<T>();

        /// <summary>
        /// 后端Worker发送处理回复结果（第三步）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="msg"></param>
        /// <param name="requestMsgId"></param>
        void SendResponse2Client<T>(T msg, string requestMsgId);

        /// <summary>
        /// 客户端接收回复消息（第四步）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="requestMsgId"></param>
        /// <returns></returns>
        T GetResponseFromWorker<T>(string requestMsgId);
    }
}
